#pragma once

#if C2504
#pragma message("VideoTab.h")
#endif

// Std
#include <vector>

// DirectX
#include <d3d11.h>

// Orbiter
#include "..\include\GraphicsAPI.h"

class D3D11Config;
class D3D11FileConfig;
class D3D11Client;

// GLobal callbacks which redirect to corresponding callbacks in VideoTab
LRESULT CALLBACK _ConfigProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
LRESULT CALLBACK _GeneralProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
LRESULT CALLBACK _VesselProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
LRESULT CALLBACK _PlanetsProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );

/*
 * Used for the launchpad Videotab of this client
 */
class VideoTab {
    friend class D3D11Client;
public:
    VideoTab( D3D11Client *pGC, HWND _hTab, HINSTANCE _hDLL );
    ~VideoTab();

    void UpdateConfig();//refrestvideodata.

    BOOL LaunchpadVideoWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );

    LRESULT ConfigProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
    LRESULT GeneralProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
    LRESULT VesselProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
    LRESULT PlanetProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );

    HWND
        mhConfig,
        mhGeneral,
        mhVessels,
        mhPlanets;
private:
    void InitVideoTab();
    void SelectWidth();
    void SelectHeight();
    void SelectFullscreen( bool fullscreen );
    void SelectOutput();
    void SelectMode();
    void SelectFullScreenWindow();
    void SelectSoftwareDevice();
    void InitTextBoxes();

    void CreateSymbolicLinks();
    bool SymbolicLinksCreated();
    bool CreateLink(const char * linkName, const char * destination);

    void InitConfigWindow();
    void InitGeneralWindow();
    void InitVesselWindow();
    void InitPlanetWindow();

    void InitConfig();
    void SaveConfig();

    oapi::GraphicsClient::VIDEODATA *mVideoData;

    DXGI_MODE_DESC *mDXGIModeDesc;
    std::vector<int> mvecModeDescIndices;

    HWND mhTab;
    int mAspect, mAspectWFac[3], mAspectHFac[3];

    HINSTANCE mhDLL;
    D3D11FileConfig *mFileConfig;
    RECT mInitTabRect;

    // Graphics Client
    D3D11Client *mGraphicsClient;

    // Config
    D3D11Config *mConfig;
};
